//
//  YJCDiscoverController.m
//  xiangzhe
//
//  Created by lyt on 16/11/7.
//  Copyright © 2016年 com.dazhebao. All rights reserved.
//

#import "YJCDiscoverViewController.h"
#import "UIImage+YJC.h"
#import "YJCButton.h"
#import "UIViewController+MMDrawerController.h"
#import "SDCycleScrollView.h"

@interface YJCDiscoverViewController ()<SDCycleScrollViewDelegate>
{
    ///轮播器
    SDCycleScrollView *_cycleView;
}
@end

@implementation YJCDiscoverViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self setupNav];
    [self setupCycleView];
    
}

# pragma mark - 轮播器
- (void)setupCycleView{
    
//    [[YJCNetWork sharedNetWork] requestWithMethod:POST serviceName:@"Menu.GetBaseInfo" parameters:nil finshed:^(id result, NSError *error) {
//        NSLog(@"%@",result);
//        NSLog(@"%@",[result class]);
//    }];

    NSArray *imageURL = @[
                          @"https://img.alicdn.com/imgextra/i2/1800948611/TB22ECeblyN.eBjSZFIXXXbUVXa_!!1800948611.jpg",
                          @"https://img.alicdn.com/imgextra/i3/889471998/TB236M.tFXXXXagXpXXXXXXXXXX_!!889471998.jpg",
                          @"https://img.alicdn.com/imgextra/i3/1800948611/TB2m89hbjm2.eBjSZFtXXX56VXa_!!1800948611.jpg"
                          ];
    _cycleView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0,[UIScreen mainScreen].bounds.size.width , 158) delegate:self placeholderImage:[UIImage imageNamed:@"def_photo"]];
    _cycleView.imageURLStringsGroup = imageURL;
    [self.tableView addSubview:_cycleView];
}



#pragma mark - tableview 代理数据源方法
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 5;
}


#pragma mark - 设置导航栏

- (void)setupNav{
    
    UIButton *leftBtn = [[YJCButton alloc] init];
    [leftBtn setTitle:@"频道" forState: UIControlStateNormal];
    [leftBtn setImage:[UIImage imageNamed:@"shape"] forState:UIControlStateNormal];
    leftBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [leftBtn addTarget:self action:@selector(channelBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [leftBtn sizeToFit];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftBtn];
    
    
    
    
    UIButton *rightBtn = [[YJCButton alloc] init];
    [rightBtn setTitle:@"消息" forState: UIControlStateNormal];
    rightBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [rightBtn addTarget:self action:@selector(messageBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [rightBtn setImage:[UIImage imageNamed:@"comments"] forState:UIControlStateNormal];
    [rightBtn sizeToFit];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightBtn];
    
    
    
    // 搜索栏
    UISearchBar *searchBar = [[UISearchBar alloc] init];
    searchBar.placeholder = @"请输入你喜欢的宝贝";
    
    self.navigationItem.titleView = searchBar;
    
    
}

#pragma mark - 按钮点击事件的实现
- (void)channelBtnClick{
    NSLog(@"点击了频道按钮");
    [self.mm_drawerController toggleDrawerSide:MMDrawerSideLeft animated:YES completion:nil];
}

- (void)messageBtnClick{
    
    NSLog(@"消息点击了");
}


@end
